package com.api.shopapi.service.impl;

import com.api.shopapi.entity.Cashier;
import com.api.shopapi.entity.dto.CashierDTO;
import com.api.shopapi.mapper.CashierMapper;
import com.api.shopapi.service.CashierService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("CashierServiceImplOne")
public class CashierServiceImpl implements CashierService {

    @Autowired
    private CashierMapper cashierMapper;

    @Override
    public int insert(Cashier cashier) {
        return cashierMapper.insert(cashier);
    }

    @Override
    public int update(Cashier cashier) {
        return cashierMapper.update(cashier);
    }

    @Override
    public Cashier getByCashierCode(String cashierCode) {
        return cashierMapper.getByCashierCode(cashierCode);
    }

    @Override
    public Cashier getByUserCode(String userCode) {
        return cashierMapper.getByUserCode(userCode);
    }

    @Override
    public PageInfo<CashierDTO> getPage(int pageIndex, int pageSize, String name, int status, String businessCode) {
        PageHelper.startPage(pageIndex,pageSize);
        List<CashierDTO> cashierDTOList = cashierMapper.getPage(name, status, businessCode);
        return new PageInfo<>(cashierDTOList);
    }

    @Override
    public List<CashierDTO> getList(String businessCode) {
        return cashierMapper.getList(businessCode);
    }


    /**
     * 商家查看收银员列表
     * */
    @Override
    public
    PageInfo<Cashier> PageByBusinessCode(int pageIndex,int pageSize,String name,String businessCode){
        PageHelper.startPage(pageIndex,pageSize);
        List<Cashier> cashierDTOList = cashierMapper.ListByBusinessCode(name, businessCode);
        return new PageInfo<>(cashierDTOList);
    }


    /**
     * 政府查看收银员列表
     * */
    @Override
    public
    PageInfo<Cashier> PageByGovernmentCodeBusinessCode(int pageIndex,int pageSize,String governmentCode,String businessCode){
        PageHelper.startPage(pageIndex,pageSize);
        List<Cashier> cashierDTOList = cashierMapper.ListByGovernmentCodeBusinessCode(governmentCode,businessCode);
        return new PageInfo<>(cashierDTOList);
    }



}
